// pages/index/function/pay/pay-detail/pay-detail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    goodsItem: [{
        goodsId: "0",
        goodsName: "薯片",
        goodsImage: "../../../../../../image/timg.jpg",
        quantity: 5,
        retailPrice: 10
      },
      {
        goodsId: "1",
        goodsName: "浪味仙贝",
        goodsImage: "../../../../../../image/timg.jpg",
        quantity: 3,
        retailPrice: 25
      },
      {
        goodsId: "2",
        goodsName: "浪味仙贝",
        goodsImage: "../../../../../../image/timg.jpg",
        quantity: 3,
        retailPrice: 25
      },
      {
        goodsId: "3",
        goodsName: "浪味仙贝",
        goodsImage: "../../../../../../image/timg.jpg",
        quantity: 3,
        retailPrice: 25
      },
    ],
    totalPrice: 366,
    realPrice: 366,
    discount: '',
    payId:"",
    currentPrice:'',
    change:0
    //change是找零，默认0，如果使用现金支付才会更新
  },
  onDiscount: function(e) {
    var that =this;
    this.setData({
      discount: e.detail.value,
      realPrice: that.data.totalPrice - e.detail.value
    })
  },
  onCurrent:function(e){
    var that =this;
    this.setData({
      currentPrice: e.detail.value,
      change: e.detail.value-that.data.realPrice
    })
  },
  showModal(e) {
    this.setData({
      modalName: e.currentTarget.dataset.target
    })
  },
  hideModal(e) {
    this.setData({
      modalName: null
    })
  },
 
  goDoneDetail(e){
    var payId = e.currentTarget.dataset.payid;
    this.setData({
      payId: payId
    })
    console.log(payId);
    wx.navigateTo({
      url: "../pay-done-detail/pay-done-detail"
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})